<?php defined('RUN_KATANA') or die('Restricted access'); ?>
<div class="prospector list row-fluid row">
	<div class="prospect-list latest span8 col-md-8">
		<div class="prospect-list-padding">
			<?php $adc->setViewObject('AdLatest'); ?>
            <?php if($katana->getId() == 23): ?>
			<div class="section-title">
            	<div class="row-fluid row">
                    <h3 class="span4 col-md-4 nomargin"><?php echo ucfirst($txt->getWord('latest_ads')); ?>&nbsp;&nbsp;</h3>
                    <div class="span8 col-md-8">
                        <div class="pagination pagination-small nomargin pull-right"><?php echo $adc->getPager()->getLinksHTML(6); ?></div>
                    </div>
                </div>
			</div>
            <?php else: ?>
                <h3 class="section-title">
                <?php echo ucfirst($txt->getWord('latest_ads')); ?>&nbsp;&nbsp;
                <a href="/list/ad/"><?php echo ucfirst($txt->getWord('view').' '.$txt->getWord('all')); ?> >></a>
            </h3>
            <?php endif; ?>
            <div class="v-space">&nbsp;</div>
			<?php
			$i = 0;
			if(count($adc->getAds('frontpage')) > 0)
			{
				foreach($adc->getAds('frontpage') as $ad)
				{
					if(!defined('RUN_IFRAME'))
					{
						if(($adc->getSetting('ListBanners') > 0) && (($i%$adc->getSetting('ListBanners')) == 0))
						{
							if(is_file(TEMPLATES_PATH.'sites/'.$katana->getId().'/layout/objects/banners/bannerProspectList-'.$i.'.php'))
							{ 
								echo '<div class="visible-xs visible-phone">';
								require(TEMPLATES_PATH.'sites/'.$katana->getId().'/layout/objects/banners/bannerProspectList-'.$i.'.php'); 
								echo '</div>';
							}
						}
					}
					$i++;
					if(is_file($adc->getViewPath().get_class($ad).'LatestItem.php'))
					{ require($adc->getViewPath().get_class($ad).'LatestItem.php'); }
					else
					{
						if(is_file($adc->getViewPath().'AdLatestItem.php'))
						{ require($adc->getViewPath().'AdLatestItem.php'); }
						else
						{ 
							if(is_file($adc->getViewPath().get_class($ad).'Item.php'))
							{ require($adc->getViewPath().get_class($ad).'Item.php'); }
							else
							{
								if(is_file($adc->getViewPath().'AdItem.php'))
								{ require($adc->getViewPath().'AdItem.php'); }
							}
						}
					}
					
					$katana->TrackViews['am_ads'][$ad->getId()]['table'] = 'am_ads';
					$katana->TrackViews['am_ads'][$ad->getId()]['where'] = 'id='.$ad->getId();
					$katana->TrackViews['am_ads'][$ad->getId()]['set'] = 'ViewsList=ViewsList+1';
				}
			}
			?>
            <div class="h-space" style="height:10px;"></div>
			<div class="section-title">
				<div class="pagination pagination-centered pagination-small nomargin">
					<?php echo $adc->getPager()->getLinksHTML(6); ?>
				</div>
			</div>
            <?php require(TEMPLATES_PATH.'sites/'.$katana->Id.'/layout/objects/banners/bannerLatestAds.php'); ?>
		</div>
	</div>
	<?php if($deviceType=='computer'): ?>
	<div class="prospect-list gallery span4 col-md-4">
		<div class="prospect-list-padding">
			<?php 
			$adc->setViewObject('AdGallery');
			$adc->getAds();
			?>
            <div class="section-title"><h3 class="nomargin"><?php echo ucfirst($txt->getWord('ads_gallery')) ?></h3></div>
            <div class="v-space">&nbsp;</div>
			<?php
			if(count($adc->getAdsGallery(5)) > 0)
			{
				$i = 0;
				foreach($adc->getAdsGallery(5) as $ad)
				{
					if(!defined('RUN_IFRAME'))
					{
						if(($adc->getSetting('GalleryBanners') > 0) && (($i%$adc->getSetting('GalleryBanners')) == 0))
						{
							if(is_file(TEMPLATES_PATH.'sites/'.$katana->getId().'/layout/objects/banners/bannerProspectGalleryList-'.$i.'.php'))
							{ 
								echo '<div class="gallery-banner">';
								require(TEMPLATES_PATH.'sites/'.$katana->getId().'/layout/objects/banners/bannerProspectGalleryList-'.$i.'.php'); 
								echo '</div>';
							}
						}
					}
					
					if(is_file($adc->getViewPath().get_class($ad).'GalleryItem.php'))
					{ require($adc->getViewPath().get_class($ad).'GalleryItem.php'); }
					else
					{
						if(is_file($adc->getViewPath().'AdGalleryItem.php'))
						{ require($adc->getViewPath().'AdGalleryItem.php'); }
					}
					$katana->TrackViews['am_ads'][$ad->getId()]['table'] = 'am_ads';
					$katana->TrackViews['am_ads'][$ad->getId()]['where'] = 'id='.$ad->getId();
					$age 		= strtotime($ad->getDateModified());
					$datediff 	= time() - $age;
					$daysage 	= floor($datediff/(60*60*24))+1;
					//echo $daysage;
					//$daysage	= 0;
					//echo (5-$i)+$daysage;
 					$katana->TrackViews['am_ads'][$ad->getId()]['set'] = 'ViewsList=ViewsList+1 , ViewsGallery=ViewsGallery+'.((5-$i)+$daysage);
					$i++;
				}
			}
			?>
			
		</div>
	</div>
	<?php endif; ?>
</div>
<?php if(($katana->getId() == 23) && ($deviceType=='computer')): ?>
<div class="h-space" style="height:10px;"></div>
<div class="feeds-list-padding"><?php if($katana->getId() == 23){ require($katana->getModPath(52)); }?></div>
<?php endif; ?>
